package net.esj.basic.utils.writer;

public abstract class AbstractWriter implements Writer {

	private boolean writeIfNull = true;
	
	protected final boolean canWrite(Signed exists,Signed input){
		if(input==null){
			return true;
		}
		boolean can = false;
		if(exists==null){
			can = writeIfNull;
		}else{
			for(String str : exists.groups()){
				for(String s : input.groups()){
					if(str.equals(s)){
						can |= true;
					}else{
						can |= false;
					}
				}
			}
		}
		return can;
	}

	public void setWriteIfNull(boolean writeIfNull) {
		this.writeIfNull = writeIfNull;
	}
	
}
